package com.hunktimes.wholesale.ui.pages

import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.hunktimes.wholesale.R
import com.hunktimes.wholesale.base.BasePageFragment
import com.hunktimes.wholesale.databinding.FragmentCreateOrderBinding
import com.hunktimes.wholesale.util.Constants
import com.hunktimes.wholesale.util.L

/**
 * Author: Delete
 * Date: 2020/7/28 14:14
 * Description:
 *
 */
class CreateOrderFragment : BasePageFragment(R.layout.fragment_create_order) {
    override val titleRes: Int
        get() = R.string.title_create_order

    lateinit var viewBinding: FragmentCreateOrderBinding
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        viewBinding = FragmentCreateOrderBinding.bind(view)
    }

    override fun onStart() {
        super.onStart()
        initcreateOrder()

        viewBinding.addressBarChangeTv.setOnClickListener {
            rootNavController.navigate(R.id.action_navigation_create_order_to_navigation_address_list)
        }
    }

    override fun onResume() {
        super.onResume()
        arguments?.let {
            val address = it.getString(Constants.key_receive_address)
        }
    }

    val createOrderAdapter = CreateOrderAdapter()
    fun initcreateOrder() {
        val createOrderLm = LinearLayoutManager(requireContext())
        createOrderLm.orientation = LinearLayoutManager.VERTICAL
        viewBinding.createOrderRcv.layoutManager = createOrderLm
        viewBinding.createOrderRcv.adapter = createOrderAdapter

        val data = mutableListOf<String>()
        for (i in 1..3) {
            data.add("create order item $i")
        }
        createOrderAdapter.data = data
    }
}

class CreateOrderAdapter : BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_order_goods) {
    override fun convert(holder: BaseViewHolder, item: String) {

    }

}